#!/usr/bin/python
# -*- coding:utf-8 -*-
# @author  : micah
# @time    :  
# @function: 
# @version :


import pymysql


def delete_data():
    db = pymysql.connect(host='localhost', port=3305, user='root', password='123456', db='python_test_1')
    cursor = db.cursor()

    sql = """
    delete from employee where sex='%s'
    """ % '女'

    try:
        cursor.execute(sql)
        db.commit()
        print('数据删除成功')
    except Exception as e:
        print('删除失败:', e)
        db.rollback()
    finally:
        cursor.close()
        db.close()


delete_data()
